<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('跟进历史')" />
</head>

<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>

</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "business/record";
    var id=[[${id}]];
    $(function() {
        var options = {
            url: prefix + "/hisList?id="+id,
            sortName: "createTime",
            sortOrder: "desc",
            modalName: "跟进",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            clickToSelect: false,
            rememberSelected: false,
            pagination: false,
            columns: [ {
                field: 'id',
                title: '主键',
                visible: false
            },
                {
                    field: 'followUpTime',
                    title: '跟进时间'
                },
                {
                    field: 'customerName',
                    title: '客户名称'
                },
                {
                    field: 'chatInformation',
                    title: '跟进内容'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="deleteId(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');

                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);

    });
    function deleteId(id){
        $.modal.confirm("确认此条?此操作不可逆", function() {
            $.operate.get(prefix+"/remove?id="+id,function(result){
                $.operate.ajaxSuccess(result);
            });
        });
    };
    /**
     * 计算出相差天数
     * @param secondSub
     */
    function formatTotalDateSub (secondSub) {
        var days = Math.floor(secondSub / (24 * 3600));     // 计算出小时数
        var leave1 = secondSub % (24*3600) ;                // 计算天数后剩余的毫秒数
        var hours = Math.floor(leave1 / 3600);              // 计算相差分钟数
        var leave2 = leave1 % (3600);                       // 计算小时数后剩余的毫秒数
        var minutes = Math.floor(leave2 / 60);              // 计算相差秒数
        var leave3 = leave2 % 60;                           // 计算分钟数后剩余的毫秒数
        var seconds = Math.round(leave3);
        return days + " 天 " + hours + " 时 " + minutes + " 分 " + seconds + ' 秒';
    }

</script>
</body>
</html>